package java1;
import java.util.Scanner;

public class Number {
    public static void main(String[] args) {
        // TODO 自动生成的方法存根
        System.out.print("请输入一个十进制整数：");
        Scanner input = new Scanner(System.in);
        int x = input.nextInt();
        final int m = x;
        int y;
        int n;
        String binary ="";
        int count = 0;
        //将负数先转换成正数
        if(x < 0){
            n = -x;
        }
        else
            n = x;

        while(n!=0){
            count++;
            y = n % 2;//求余数
            binary = y + binary;
            n /= 2;//求商
            if (count % 4 == 0){
                binary = "_" + binary;
            }
        }
        while (binary.length() < 38)
        {
            count++;
            binary = 0 + binary;
            if (count % 4 == 0){
                binary = "_" + binary;
            }
        }
        if (x >= 0){
            binary = "0" + binary;
        }
        else {
            binary = "1" + binary;
        }
        System.out.println(m + "的二进制形式是：" + binary);
    }
}
